package work02.w5.control.server;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class MyCalendarServeCenter {
	Set<MyEventListener> listeners = new HashSet<MyEventListener>();
	private static MyCalendarServeCenter me;
	private static boolean isInit=false;
	public static MyCalendarServeCenter getInstance(){
		if(me==null)
			me=new MyCalendarServeCenter();
		return me;
	}
	/**
	 * 配置服务,启动挂载的服务
	 */
	private MyCalendarServeCenter(){
		if(!isInit)
		init();
	}
	
	private void init() {
		isInit=true;

	}
	public synchronized void sendMyEvent(MyEvent e) {
		Iterator<MyEventListener> its = listeners.iterator();
		while (its.hasNext()) {
			MyEventListener it = its.next();
			it.occurEvent(e);
		}
	}

	public synchronized void addCalendarEventListener(MyEventListener l) {
		listeners.add(l);
	}
	public synchronized void removeCalendarEventListener(MyEventListener l) {
		listeners.remove(l);
	}
}
